//
//  ZZProgressView.m
//  XiangYu
//
//  Created by YYKJ on 2017/6/7.
//  Copyright © 2017年 YYKJ. All rights reserved.
//

#import "ZZProgressView.h"

#define KProgressBorderWidth 2.0f
#define KProgressPadding 1.0f
#define KProgressColor [UIColor colorWithRed:0/255.0 green:191/255.0 blue:255/255.0 alpha:1]

@interface ZZProgressView ()

@property (nonatomic, strong) UIView *proView;


@end

@implementation ZZProgressView

-(void)layouSubViews{

    self.backgroundColor = [UIColor whiteColor];
    [self.layer setMasksToBounds:YES];
    [self.layer setCornerRadius:self.bounds.size.height*0.5];
    [self.layer setBorderColor:[KProgressColor CGColor]];
    [self.layer setBorderWidth:KProgressBorderWidth];
    
    _proView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 50, self.height)];
    [self addSubview:_proView];
    [_proView.layer setMasksToBounds:YES];
    [_proView.layer setCornerRadius:(self.bounds.size.height - (KProgressBorderWidth + KProgressPadding) * 2) * 0.5];
    [_proView setBackgroundColor:[UIColor BVBaseOrangeColor]];
    
}

- (void)setProgress:(CGFloat)progress
{
    _progress = progress;
    
    CGFloat margin = KProgressBorderWidth + KProgressPadding;
    CGFloat maxWidth = self.width - margin * 2;
    
    NSLog(@"--------%f-----%f",maxWidth,self.bounds.size.width);
    
    _proView.frame = CGRectMake(0, 0, maxWidth * progress, self.height);
}

- (void)drawRect:(CGRect)rect {
    
}

@end
